package model.student;

import java.io.Serializable;
import java.util.ArrayList;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="department")
public class Department implements Serializable
{
	private static final long serialVersionUID = -2323185852331104794L;

	private static int i = 0;
	
	@XmlAttribute
	private String id = "";
	
	@XmlAttribute
	private String name = "";
	
	@XmlElement(name = "direction")
	private ArrayList<Direction> directions = new ArrayList<Direction>();
	
	public Department() {}
	
	public Department(String name)
	{
		i++;
		this.id = i + "";
		this.name = name;
	}
	
	public Direction createDirection(String name)
	{
		Direction direction = new Direction(name);
		directions.add(direction);
		return direction;
	}

	public ArrayList<Direction> getDirections()
	{
		return directions;
	}
	
	public String toString()
	{
		String out = "";
		for (int i = 0; i < directions.size(); i++)
		{
			out += directions.get(i) + "\n";
		}
		return "Department id(" + id + ") -> Name: " + name + "\n" + out;
	}

	public String getId()
	{
		return id;
	}

	public String getName()
	{
		return name;
	}
}
